package cn.corgy.Observer;

import java.util.ArrayList;
import java.util.List;

public class Person {
    private final List<Observer> observers = new ArrayList<>();
    private int age;

    public int getAge() {
        return this.age;
    }

    public void setAge(int age) {
        this.age = age;
        notifyAllObserver();
    }

    public void add(Observer observer) {
        observers.add(observer);
    }

    public void notifyAllObserver() {
        for (Observer observer : observers) {
            observer.update();
        }
    }
}
